<div class="table-tools">
    <a href="__URL__/addUI" class="btn btn-info" title="添加公告"><i class="fa fa-copy"></i> 添 加 </a>
    <!--<button type="submit" class="btn btn-primary" title="删除勾选的资源"><i class="glyphicon glyphicon-remove"></i> 删 除 </button>-->
    <!--<button type="button" class="btn btn-success" title="重新排序资源" onclick="sortQuestions()"><i class="fa fa-copy"></i> 重 排 </button>-->
    <form class="form-inline" method="post" action="__URL__/index" id="search_form"  role="form">
        <input type="hidden" name="pagenum" id="pagenum_hidden" value="{$page.pagenum}">
        <input type="hidden" name="count" value="{$recordcount}">
    </form>
    <p>公告列表</p>
</div>

<table id="users-table" class="table table-striped table-hover table-condensed datatable">
    <thead>

    <tr id="user_{$notice.id}">
        <th width="50px">ID</th>
        <th>标题</th>
        <th>内容</th>
        <th>跳转URL(可添加到轮播图跳转URL中)</th>
        <!--<th width="150px">操作</th>-->
        <!--<th width="80px">排序</th>-->
    </tr>
    </thead>
    <tbody>
    <volist name="list" id="notice">
        <tr>
            <!--<td width="50px"><input name='id[]' type="checkbox" value="{$notice.id}" /></td>-->
            <td class="question-name">{$notice.id}</td>
            <td class="question-name">{$notice.title}</td>
            <td class="question-name"><a href="__URL__/content/{$notice.id}" class="btn btn-default btn-rounded btn-condensed btn-sm" title="查看内容"><span class="fa fa-pencil">查看</span></a></td>
            <td class="question-name">{$notice.url}</td>
            <td width="150px">
            <a href="__URL__/editUI/{$notice.id}" class="btn btn-default btn-rounded btn-condensed btn-sm" title="编辑公告"><span class="fa fa-pencil">编辑</span>
            </a>
            <a onclick="deleteById('{$notice.id}')" class="btn btn-default btn-rounded btn-condensed btn-sm" title="删除公告"><span class="glyphicon glyphicon-remove">删除</span></a>
            </td>
            <!--<td width="80px"><input name="sort[{$notice.id}]" class="sort-input" type="text" value="{$notice.sort}" /></td>-->
        </tr>
    </volist>
    </tbody>
</table>
<nav style="float:right">
    <spen class="total">共 {$recordcount}条记录</spen>
    <div class="fr">
        <ul class="pagination">
            <eq name="page['pagenum']" value="1">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('1')">«</a></li>
            <foreach name="page.pagenums" item="vo">
                <eq name="page['pagenum']" value="$vo">
                    <li class="active"><a href="#">{$vo}</a></li>
                    <else/>
                    <li><a href="#" onclick="gotoPage('{$vo}')">{$vo}</a></li>
                </eq>
            </foreach>
            <eq name="page['pagenum']" value="$page.endPage">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('{$page.totalpage}')">»</a></li>
        </ul>
    </div>
</nav>
<div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body" id="hint_content">
            </div>
            <div class="modal-footer">
                <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
<script>
    function gotoPage(pagenum) {
        //提交form
        $('#pagenum_hidden').val(pagenum);
        $('#search_form').submit();
    }
    function deleteById(id) {
        console.info(id);
        $("#delete_modal").modal();
        $('#delete_confirm').on('click', function(){
            $("#delete_modal").modal('hide');
            $.ajax({
                type: "GET",
                url: "__URL__/delete",
                data: {id: id},
                dataType: "json",
                success: function (data) {
                    console.info(data);
                    $("#hint_content1").empty().append(data.message);
                    $("#my-alert1").modal('show');
                    if (data.check) {
                        $('#image_' + id).hide();
                        $('.total').empty().append('共 '+data.count+' 条记录');
                    }
                },
                error: function (data) {
                    $("#hint_content1").empty().append('服务器忙');
                    $("#my-alert1").modal('show');
                }
            });


        })
    }
</script>